"""
1.数据准备
"""
from sklearn import datasets
from sklearn.model_selection import train_test_split

iris = datasets.load_iris()
x = iris.data
y = iris.target
# x, y = datasets.load_iris(return_X_y=True)
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.3)

"""
2.建立模型
"""
from sklearn.neighbors import KNeighborsClassifier
knn = KNeighborsClassifier()

"""
3.训练
"""
knn.fit(x_train, y_train)

"""
4.测试
"""
acc = knn.score(x_test, y_test)
print(acc)
